package spring.spring_blog.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import spring.spring_blog.common.interceptor.loginInterceptor;

@Configuration
public class webConfig implements WebMvcConfigurer {

    @Autowired
    loginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截哪些请求
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/blog/**")
                .excludePathPatterns("/blog/login")
                .excludePathPatterns("/blog/register")
                .excludePathPatterns("/**/*.html","/**/*.css", "/**/*.js", "/**/*.png");
    }
}
